home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_1 / fft < prev    next >
Internet Message Format  |  1995-03-31  |  4KB

  1. From comp.sys.handhelds Fri May 24 23:21:12 1991
  2. Path: seq!ecsgate!mcnc!gatech!udel!wuarchive!uunet!mcsun!i2unix!alessia!ares
  3. From: ares@alessia.dei.unipd.it (Nicola Catacchio 259126)
  4. Newsgroups: dei.comp.hp28,comp.sys.handhelds
  5. Subject: ffffffft for hp48
  6. Keywords: {reposted}
  7. Message-ID: <11220@alessia.dei.unipd.it>
  8. Date: 20 May 91 14:01:22 GMT
  9. Organization: D.E.I. Universita' di Padova (Italy)
  10. Lines: 140
  11. Xref: seq comp.sys.handhelds:8091
  12.  
  13.  
  14.     I repost my fft version again, because the first time i posted
  15. a listing with some program undocumented in it.Those progs was some attempt
  16. to make tthe program run faster on real sequences, but I couldn't get
  17. any result.
  18.     The above is a reply to a reader that asked me some explanation 
  19. about the program and the fft .
  20.     I'm sorry, but there aren't so many answers to give: the fft is 
  21. an acronym to indicate a specific algorithm to perform dft, that is a
  22. VERY particular caseof the Fourier transform.
  23.     The algorithm derived directly from the Fourier integal is too
  24. slow and inefficient, so the fft algorithm is universally applied.
  25.     The program 'PLOT' shows the ABS value of each element in the 
  26. vector output of FFT. It is necessary to perform the ABS, infact the 
  27. algorithm gives a complex vector as output.
  28.     What does it means? This vector is a set of ordered samples of
  29. the continuous fourier transform: The dft operate only on periodic functions
  30. defined on discrete domains.The function must be seen on a period and
  31. sampled. The more you increase the number of samples and the interval on
  32. which is sampled the more you can take an approximation of the continuous
  33. case.
  34.     An example could be :
  35. Take a set of samples of the function 'IFTE(X,SIN(X)/X,1)' on a interval
  36. large enough, i.e.
  37. 2: 'IFTE(X,SIN(X)/X,1)'
  38. 1:      { X -20 20 }
  39. press [SAMP]
  40. take a set of samples of its  fourier transform: [FFT]
  41. then,to to make a representation, perform the ABS value of each element:[ABSV]
  42. take a plot: [PLOT]
  43.     The result will be an approximation of a function RECT, that is 
  44. diffrent from zero only in an interval centered in 0.
  45.     Don't forget that this is a representation of a periodic function:
  46. the more you increase sampling points, the greater will become the period
  47. width. Dually, the more you increase the width of the sampling interval,
  48. the better is the definition you get in the calculus of the fourier
  49. tranform.
  50.  
  51. |------------------------------------------------------------------------------|
  52. |Nicola Catacchio        |E-mail:  ares@alessia.unipd.it                       |
  53. |Universita' di Padova   |mail  :  Cannaregio 4389, Venezia, Italy             |
  54. |                        |phone#:  041/5222516                                 |
  55. |------------------------------------------------------------------------------|
  56.  
  57. %%HP: T(3)A(R)F(.);
  58. DIR
  59.   SAMP
  60.     \<< EVAL 3 PICK 3
  61. PICK SWAP - n / \-> F
  62. A B X S
  63.       \<< A X STO 1 n
  64.         START F
  65. EVAL S X STO+
  66.         NEXT n
  67. \->ARRY
  68.       \>>
  69.     \>>
  70.   n 64
  71.   ABSV
  72.     \<< OBJ\-> EVAL \-> N
  73.       \<< 1 N
  74.         START N
  75. ROLL C\->R SQ SWAP SQ
  76. +
  77.         NEXT N
  78. \->ARRY
  79.       \>>
  80.     \>>
  81.   PLOT
  82.     \<< DUP OBJ\-> EVAL
  83. \-> N
  84.       \<< 1 N 2 /
  85.         START N
  86. ROLL
  87.         NEXT { N 1
  88. } \->ARRY STO\GS
  89. BARPLOT GRAPH {
  90. PPAR \GSPAR \GSDAT PICT
  91. } PURGE
  92.       \>>
  93.     \>>
  94.   IFFT
  95.     \<< OBJ\-> EVAL \-> N
  96.       \<< 2 N 1 -
  97.         FOR I I
  98. ROLL
  99.         NEXT N IBIT
  100. DTEM \->ARRY N /
  101.       \>>
  102.     \>>
  103.   FFT
  104.     \<< OBJ\-> 1 GET
  105. IBIT DTEM \->ARRY
  106.     \>>
  107.   DTEM
  108.     \<< 1 OVER \-> H N
  109.       \<< -1 1 ROT LN
  110. 2 LN /
  111.         START 1 N 2
  112. + DUP H - 1 +
  113.           FOR J J 3
  114.             FOR I I
  115. H - ROLL OVER * I
  116. ROLL SWAP DUP2 -
  117. ROT ROT + I ROLLD I
  118. H - ROLLD H DUP +
  119. NEG
  120.             STEP
  121. OVER * -1
  122.           STEP DROP
  123. H DUP + 'H' STO
  124. CONJ \v/ CONJ
  125.         NEXT DROP N
  126.       \>>
  127.     \>>
  128.   IBIT
  129.     \<<
  130.       IF DUP 2 >
  131.       THEN DUP 2 /
  132. DUP \-> N
  133.         \<< 1 + 3 ROT
  134.           FOR I
  135.             IF DUP
  136. I 1 - >
  137.             THEN I
  138. ROLL OVER 1 + ROLLD
  139. DUP ROLL I ROLLD
  140.             END N
  141. SWAP
  142.             WHILE
  143. DUP2 <
  144.             REPEAT
  145. OVER - SWAP 2 /
  146. SWAP
  147.             END +
  148.           NEXT
  149.         \>>
  150.       END
  151.     \>>
  152. END
  153.  
  154.